package presentation;

import controleur.GestionProduit;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;


public class FenetreSuppression extends JFrame implements ActionListener {

	private JButton btSupprimer;
	private GestionProduit gp;
	private JComboBox combo;

	public FenetreSuppression(GestionProduit g) {

		gp = g;
		setTitle("Suppression");
		setBounds(500, 500, 200, 105);
		Container contentPane = getContentPane();
		contentPane.setLayout(new FlowLayout());
		btSupprimer = new JButton("Supprimer");

		combo = new JComboBox(gp.listeProduits());
		combo.setPreferredSize(new Dimension(100, 20));
		contentPane.add(new JLabel("Produit"));
		contentPane.add(combo);
		contentPane.add(btSupprimer);

		btSupprimer.addActionListener(this);

		this.setVisible(true);
	}

	public void actionPerformed(ActionEvent e) {
		if (e.getSource () == btSupprimer) {
			gp.supprimerProduit((String)combo.getSelectedItem());
		}
		this.dispose();
	}

}
